package com.zs.main;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert;
import com.zs.framework.code.generator.ZSCodeGenerator;

/**
 * Copyright 2020 ZS Network Co., Ltd. All rights reserved.
 * 本文件仅限于正数网络技术有限公司内部传阅，禁止外泄以及用于其他的商业目的。
 * Created by yuancong on 2022/12/1.
 */
public class CodeGenerator {
    private static String artifactName = "monitor-optimize";
    private static String packageName = "com.zs";

    private static DataSourceConfig prepareDataSource() {
        DataSourceConfig dsc = new DataSourceConfig();
        dsc.setDbType(DbType.MYSQL);
        dsc.setTypeConvert(new MySqlTypeConvert());
        dsc.setUsername("root");
        dsc.setPassword("123456");
        dsc.setUrl("jdbc:mysql://192.168.252.220:13306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true&autoReconnect=true");
        dsc.setDriverName("com.alibaba.druid.pool.DruidDataSource");
        return dsc;
    }

    public static void main(String[] args) {
        String[] tables = {"t_demo_user"};
        String tablePrefix = "t_"; // 默认值,可不填
        ZSCodeGenerator zsCodeGenerator = new ZSCodeGenerator(CodeGenerator.class,artifactName,packageName);
        zsCodeGenerator.setDataSourceConfig(prepareDataSource())
                .setTables(tables)
                .setTablePrefix(tablePrefix)
                .setAuthor("yuancong");

        zsCodeGenerator.generate();
    }
}
